package com.oscarmovie.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oscarmovie.model.Role;

public class RoleDaoImpl extends HibernateDaoSupport implements RoleDao {

	
	public void save(Role role) {
		getSession().saveOrUpdate(role);
	}

	public Role load(int id) {
		Role role = (Role)getSession().load(Role.class, id);
		return role;
	}
	
	
	public List<Role> loadAll() {
		Query query = getSession().createQuery("from Role order by id");
		query.setCacheable(true);
		List<Role> list = (List<Role>)query.list();
		return list;
	}
	
}
